import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import HiUi from 'hi-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css
import '@/styles/project.scss' // project css 01521
// import 'kindeditor/themes/default/default.css'

import VueKindEditor from 'vue-kindeditor'
import 'kindeditor/kindeditor-all-min.js'
import 'kindeditor/themes/default/default.css'

import _ from 'lodash'

import App from './App'
import store from './store'
import router from './router'
import hiSetting from './hiSetting'
//import Context from './context'
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters
import { HiDataSetContainer } from "hi-ui";
import WebScoketManager from './websocket' // global filters
import i18n from './lang' // internationalization

import request from "./utils/request";
import 'hi-ui/lib/hi-ui.css'
//import {utils} from 'hi-ui'
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
// import { mockXHR } from '../mock'
// if (process.env.NODE_ENV === 'production') {
//   // mockXHR()
// }

Vue.use(Element, {
  size: Cookies.get('size') || 'mini', //'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(HiUi, {});

import { VueJsonp } from 'vue-jsonp'
Vue.use(VueJsonp)

Vue.prototype.$dsContainer = new HiDataSetContainer({
  request: request,
  saveUrl: hiSetting.saveUrl,
  queryUrl: hiSetting.queryUrl,
  datasetUrl: hiSetting.datasetUrl,
  policyUrl: hiSetting.policyUrl,
  
  cacheKeyPrefix: function () {
    return window.location.hash + "/";
  }
})

Vue.prototype.$HI = {
  projectName: hiSetting.projectName,
  request: request,
  queryOperate: 'like',
  pageSize: 20,
  saveUrl: hiSetting.saveUrl,
  queryUrl: hiSetting.queryUrl,
  datasetUrl: hiSetting.datasetUrl,
  policyUrl: hiSetting.policyUrl,
  upload: hiSetting.upload,
  download: hiSetting.download,
  review: hiSetting.review,
  getFlowInfo: hiSetting.getFlowInfo,
  getApprovalInfo: hiSetting.getApprovalInfo,
  processFlow: hiSetting.processFlow,
  queryTask: hiSetting.queryTask,
  withdrawtask: hiSetting.withdrawtask,
  taskDiagram: hiSetting.taskDiagram,
  openOrdernumber: hiSetting.openOrdernumber,
  editorImgServer :hiSetting.review+"?relativePath="
};


// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false
// 注册 vue-kikindeditor plugin
Vue.use(VueKindEditor)
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  ak: 'xsQ8h2NSMHy3oox93spvGISjsrFKmrpk'
})
//Vue.prototype.$context = new Context()
Vue.prototype.$websocket = new WebScoketManager()

new Vue({
  el: '#app',
  router,
  i18n,
  store,
  render: h => h(App)
})
